package com.example.demo.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 操作日志记录
 * @TableName log
 */

@Schema(description = "日志信息")
@EqualsAndHashCode(callSuper = true)
@TableName(value ="log")
@Data
public class OperLog extends BaseEntity implements Serializable {

    @Schema(description = "操作描述")
    private String title;

    @Schema(description = "业务类型")
    private String businessType;

    @Schema(description = "方法名称")
    private String method;

    @Schema(description = "请求方式")
    private String requestMethod;

    @Schema(description = "操作人类别")
    private String operatorType;

    @Schema(description = "操作人员")
    private String operName;

    @Schema(description = "部门名称")
    private String deptName;

    @Schema(description = "请求URL")
    private String operUrl;

    @Schema(description = "主机地址")
    private String operIp;

    @Schema(description = "请求参数")
    private String operParam;

    @Schema(description = "返回参数")
    private String jsonResult;

    @Schema(description = "操作状态（1正常 0异常）")
    private Integer status;


    @Schema(description = "错误消息")
    private String errorMsg;

    @Schema(description = "操作时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date operTime;

    @Serial
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    public static String entityTitle="日志";

    public static Map<String,String> getExcelCols(){
        Map<String,String> map=new LinkedHashMap<>();
        map.put("title","模块标题");
        map.put("businessType","业务类型");
        map.put("method","方法名称");
        map.put("requestMethod","请求方式");
        map.put("operatorType","操作类别");
        map.put("operName","操作人员");
        map.put("deptName","部门名称");
        map.put("operUrl","请求URL");
        map.put("operIp","主机地址");
        map.put("operParam","请求参数");
        map.put("jsonResult","返回参数");
        map.put("status","操作状态");
        map.put("errorMsg","错误消息");
        map.put("operTime","操作时间");
        return map;
    }
}